package com.uatair.system.service.impl;

import com.uatair.common.utils.DateUtils;
import com.uatair.common.utils.StringUtils;
import com.uatair.system.domain.TpPurchaserSn;
import com.uatair.system.mapper.TpPurchaserSnMapper;
import com.uatair.system.service.ITpPurchaserSnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 采购方/甲方飞机对照Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-11
 */
@Service
public class TpPurchaserSnServiceImpl implements ITpPurchaserSnService
{
    @Autowired
    private TpPurchaserSnMapper sysPurchaserSnMapper;

    /**
     * 查询采购方/甲方飞机对照
     * 
     * @param id 采购方/甲方飞机对照主键
     * @return 采购方/甲方飞机对照
     */
    @Override
    public TpPurchaserSn selectTpPurchaserSnById(Long id)
    {
        return sysPurchaserSnMapper.selectTpPurchaserSnById(id);
    }

    /**
     * 查询采购方/甲方飞机对照列表
     * 
     * @param sysPurchaserSn 采购方/甲方飞机对照
     * @return 采购方/甲方飞机对照
     */
    @Override
    public List<TpPurchaserSn> selectTpPurchaserSnList(TpPurchaserSn sysPurchaserSn)
    {
        return sysPurchaserSnMapper.selectTpPurchaserSnList(sysPurchaserSn);
    }

    /**
     * 新增采购方/甲方飞机对照
     * 
     * @param sysPurchaserSn 采购方/甲方飞机对照
     * @return 结果
     */
    @Override
    public int insertTpPurchaserSn(TpPurchaserSn sysPurchaserSn)
    {
        if (sysPurchaserSn.getPurchaser()==null || StringUtils.isEmpty(sysPurchaserSn.getSn()))
            return 0;
        if (sysPurchaserSn.getPurchaser()==1 && StringUtils.isEmpty(sysPurchaserSn.getPurchaserSn()))
            return 0;
        sysPurchaserSn.setCreateTime(DateUtils.getNowDate());
        return sysPurchaserSnMapper.insertTpPurchaserSn(sysPurchaserSn);
    }

    /**
     * 修改采购方/甲方飞机对照
     * 
     * @param sysPurchaserSn 采购方/甲方飞机对照
     * @return 结果
     */
    @Override
    public int updateTpPurchaserSn(TpPurchaserSn sysPurchaserSn)
    {
        sysPurchaserSn.setUpdateTime(DateUtils.getNowDate());
        return sysPurchaserSnMapper.updateTpPurchaserSn(sysPurchaserSn);
    }

    /**
     * 批量删除采购方/甲方飞机对照
     * 
     * @param ids 需要删除的采购方/甲方飞机对照主键
     * @return 结果
     */
    @Override
    public int deleteTpPurchaserSnByIds(Long[] ids)
    {
        return sysPurchaserSnMapper.deleteTpPurchaserSnByIds(ids);
    }

    /**
     * 删除采购方/甲方飞机对照信息
     * 
     * @param id 采购方/甲方飞机对照主键
     * @return 结果
     */
    @Override
    public int deleteTpPurchaserSnById(Long id)
    {
        return sysPurchaserSnMapper.deleteTpPurchaserSnById(id);
    }

    @Override
    public TpPurchaserSn selectSysPurchaserBySn(TpPurchaserSn sysPurchaserSn) {
        return sysPurchaserSnMapper.selectSysPurchaserBySn(sysPurchaserSn);
    }

    @Override
    public int deleteTpPurchaserSnBySN(TpPurchaserSn sysPurchaserSn) {
        if (StringUtils.isEmpty(sysPurchaserSn.getSn()) || sysPurchaserSn.getPurchaser()==null)
            return 0;
        return sysPurchaserSnMapper.deleteTpPurchaserSnBySN(sysPurchaserSn);
    }
}
